<?php

use Phinx\Migration\AbstractMigration;

class CreateBusinessPartner extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('business_partner', ['id' => 'partner_id']);
        $table->addColumn('name', 'string', ['limit' => 100, 'null' => true, 'comment' => '商家名称'])
              ->addColumn('contact_name', 'string', ['limit' => 50, 'null' => true, 'comment' => '联系人姓名'])
              ->addColumn('contact_phone', 'string', ['limit' => 20, 'null' => true, 'comment' => '联系人电话'])
              ->addColumn('province', 'string', ['limit' => 50, 'null' => true, 'comment' => '省份'])
              ->addColumn('city', 'string', ['limit' => 50, 'null' => true, 'comment' => '城市'])
              ->addColumn('district', 'string', ['limit' => 50, 'null' => true, 'comment' => '区县'])
              ->addColumn('address', 'string', ['limit' => 255, 'null' => true, 'comment' => '详细地址'])
              ->addColumn('business_license', 'string', ['limit' => 255, 'null' => true, 'comment' => '营业执照'])
              ->addColumn('logo', 'string', ['limit' => 255, 'null' => true, 'comment' => '商家logo'])
              ->addColumn('images', 'text', ['null' => true, 'comment' => '商家图片，JSON格式'])
              ->addColumn('description', 'text', ['null' => true, 'comment' => '商家描述'])
              ->addColumn('business_hours', 'string', ['limit' => 100, 'null' => true, 'comment' => '营业时间'])
              ->addColumn('business_type_id', 'integer', ['null' => true, 'comment' => '商家类型ID'])
              ->addColumn('service_level', 'string', ['limit' => 20, 'null' => true, 'default' => 'normal', 'comment' => '服务等级：normal=普通商家，vip=VIP商家'])
              ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态：0=禁用，1=启用'])
              ->addColumn('sort', 'integer', ['default' => 0, 'comment' => '排序'])
              ->addColumn('created_at', 'timestamp', ['null' => true])
              ->addColumn('updated_at', 'timestamp', ['null' => true])
              ->addIndex(['name'])
              ->addIndex(['status'])
              ->addIndex(['business_type_id'])
              ->create();
    }
} 